import httpMethod from '../enum/httpMethod';

export let restController = function (constructor: Function) {

}

export let requestMapping = function (url: string, method: httpMethod = httpMethod.GET) {
    const { container, router } = this;
    return function (target, propertyKey: string, descriptor: PropertyDescriptor) {
        console.log('requestMapping start')
        router[httpMethod[method].toLowerCase()](url, function (ctx, ...rest) {
            descriptor.value.bind(container.resolve(target.constructor.name))(ctx, ...rest);
        });
    }
}



export default function init(container, router) {
    restController = restController.bind({ container, router });
    requestMapping = requestMapping.bind({ container, router });
}